package org.rupa.core.poll.impl;

import org.rupa.core.poll.PollFactory;

import java.util.List;
import java.util.Random;

public class RandomPollFactory implements PollFactory {
    private List<String> serviceNames;

    private Random random = new Random();

    @Override
    public String poller() {
        int index = random.nextInt(serviceNames.size());
        return serviceNames.get(index);
    }

    @Override
    public void refreshServiceList(List<String> serviceNames) {
        this.serviceNames = serviceNames;
    }
}
